package com.rimi.controller;

import com.rimi.bean.News;
import com.rimi.commons.CommonResult;
import com.rimi.service.EncyclopediasService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author admin
 * @version V1.0
 * @Description: 用一句话描述该文件做什么
 * @date 2021/7/10 15:05
 */
@Slf4j
@Controller
@CrossOrigin
@Api(description = "宠物百科",tags = "宠物百科")
public class EncyclopediasController {
    @Autowired
    EncyclopediasService encyclopediasService;

    @GetMapping("/encyclopedias/common")
    @ResponseBody
    @ApiOperation("根据新闻类型查找该类型所有新闻")
    public CommonResult<List<News>> common(String type){
        List<News> news = encyclopediasService.findNewsByType(type);

        return CommonResult.onSuccess(news);
    }

}
